package com.health.userbackstage.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.health.userbackstage.mapper.MemberMapper;
import com.health.userbackstage.pojo.Member;
import com.health.userbackstage.pojo.Order;
import com.health.userbackstage.pojo.Report;
import com.health.userbackstage.pojo.result.Result;
import com.health.userbackstage.pojo.result.ResultEnum;
import com.health.userbackstage.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> implements MemberService {

    @Autowired
    private MemberMapper memberMapper;

    @Override
    public Member findOneByName(Member member) {
        Member member1 = memberMapper.selectOneByName(member);
        if (member1 == null){
            return null;
        }
        return member1;
    }

    @Override
    public Member findOneByFileNumber(Member member) {
        Member member1 = memberMapper.selectOneByFileNumber(member);
        if (member1 == null){
            return null;
        }
        return member1;
    }

    @Override
    public List<Order> findByMemberId(Long memberId) {
        return memberMapper.selectByMemberId(memberId);
    }

    @Override
    public List<Report> findReportByMemberId(Long memberId) {
        List<Report> reports = memberMapper.selectReportByMemberId(memberId);

        return reports;
    }

    @Override
    public boolean deleteReportById(Integer id) {
        int i = memberMapper.deleteReportById(id);
        if (i > 0){
            return true;
        }
        return false;
    }


}
